package consultan.vanke.com.fragment;

import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import consultan.vanke.com.R;
import consultan.vanke.com.adapter.CommonAdapter;
import consultan.vanke.com.adapter.ViewHolder;
import consultan.vanke.com.utils.SimpleToolbar;

import static com.bytedance.sdk.account.open.aweme.utils.ViewUtils.getStatusBarHeight;
import static consultan.vanke.com.utils.StatusBarUtil.setPaddingTop;
import static consultan.vanke.com.utils.StatusBarUtil.setRootView;


public class MyGZFragment extends BaseFragment {
    @BindView(R.id.simple_toolbar)
    SimpleToolbar simpleToolbar;
    @BindView(R.id.simple_toolbar_main)
    ConstraintLayout simpleToolbarMain;
    @BindView(R.id.recy_list)
    RecyclerView recyList;
    @BindView(R.id.rel_bottom)
    LinearLayout relBottom;
    private View inflate;
    private boolean isfristshow = true;
    private CommonAdapter<String> adapterCenter;
    private List<String> subjectsBeansCenter = new ArrayList<>();
    private boolean isshow;

    @Override
    protected void initViews() {
        simpleToolbar.setMainBg(getResources().getColor(R.color.white_color));
        simpleToolbar.setMainTitle("我的关注");
        simpleToolbar.setRightAginTitleText("编辑");
        simpleToolbar.setRightAginTitleColor(getResources().getColor(R.color.color_4A9DF6));
        simpleToolbar.setRightTitleClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                isshow = true;
                simpleToolbar.setRightAginTitleText("删除");
                simpleToolbar.setRightAginTitleColor((Color.parseColor("#FF6B30")));
                adapterCenter.notifyDataSetChanged();
                relBottom.setVisibility(View.VISIBLE);
            }
        });
    }

    @Override
    protected void initDatas() {
        for (int i = 0; i < 10; i++) {
            subjectsBeansCenter.add("111");
        }
        recyList.setLayoutManager(new LinearLayoutManager(_mActivity));
        adapterCenter = new CommonAdapter<String>(_mActivity, subjectsBeansCenter, R.layout.gz_item) {
            @Override
            public void onBindViewHolder(ViewHolder holder, int position) {
                super.onBindViewHolder(holder, position);
            }

            @Override
            public void convert(ViewHolder holder, String assetBean) {
                ImageView img_xuanzhong = holder.getView(R.id.img_xuanzhong);
                if (isshow) {
                    img_xuanzhong.setVisibility(View.VISIBLE);
                } else {
                    img_xuanzhong.setVisibility(View.GONE);
                }
            }
        };
        recyList.setAdapter(adapterCenter);
    }

    @Override
    protected void initEvents() {
        simpleToolbar.setLeftTitleClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                pop();
            }
        });
    }

    @Override
    protected View initContentView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        inflate = View.inflate(_mActivity, R.layout.my_gz_fragment, null);
        return inflate;
    }

    @Override
    public void onSupportVisible() {
        super.onSupportVisible();
        ViewGroup decorView = (ViewGroup) _mActivity.getWindow().getDecorView();
        View fakeStatusBarView = new View(_mActivity);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(_mActivity) + 3);
        fakeStatusBarView.setLayoutParams(params);
        fakeStatusBarView.setBackground(getResources().getDrawable(R.drawable.bg_white));
        fakeStatusBarView.setId(android.R.id.custom);
        decorView.addView(fakeStatusBarView);
        setRootView(_mActivity, false);
        setStatusBarColors(getResources().getColor(R.color.white_color), true);
    }

}
